package org.social.db.dao;

import com.sojoys.artifact.manager.DataSourceManager;
import java.sql.Connection;
import com.sojoys.artifact.build.data.base.BaseDao;
import java.util.ArrayList;
import com.sojoys.artifact.manager.JsonManager;
import java.sql.SQLException;
import com.google.common.collect.Lists;
import org.social.db.bean.DynamicCommodity;
import org.apache.commons.dbutils.handlers.MapHandler;
import com.sojoys.artifact.tools.SK_Plus;
import java.sql.ResultSet;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbutils.handlers.MapListHandler;
import com.sojoys.artifact.constant.CreateTableEnum;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import org.apache.commons.dbutils.handlers.AbstractListHandler;
import org.apache.commons.dbutils.QueryRunner;
import com.xiaoleilu.hutool.log.Log;
import static org.social.db.StaticResource.DynamicCommodityResource.*;
import java.util.Set;
import com.sojoys.artifact.constant.ArtifactErrorCode;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.tools.ToolError;
import org.apache.commons.dbutils.DbUtils;
import com.xiaoleilu.hutool.log.LogFactory;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.dbutils.ResultSetHandler;
import com.google.common.base.Joiner;
import static org.social.db.StaticResource.DynamicCommodityResource.*;
/**
 * 动态商品
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DynamicCommodityDaoImpl implements BaseDao<Integer,DynamicCommodity>{
	static Log log = LogFactory.get(DynamicCommodityDaoImpl.class);
	
	// 代理
	
	/**
	 * 私有化无参构造方法
	 */
	private DynamicCommodityDaoImpl() {}
	  
    private static final DynamicCommodityDaoImpl INSTANCE = new DynamicCommodityDaoImpl();  
    
    public static DynamicCommodityDaoImpl me() {  
        return INSTANCE;  
    }  
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(dynamicCommodity,conn);
	}
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity,Connection conn){
		return insert(dynamicCommodity,conn,TABLE_NAME);
	}
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insert(dynamicCommodity,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(dynamicCommodity,conn,tableName);
	}
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity,Connection conn,String tableName){
		
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int i = run.update(conn,sql,dynamicCommodity.getId(),dynamicCommodity.getName(),dynamicCommodity.getStoreId(),dynamicCommodity.getGridString(),dynamicCommodity.getTagIcon(),dynamicCommodity.getOpenContType(),dynamicCommodity.getOpenContVal(),dynamicCommodity.getWeight(),dynamicCommodity.getLimitType(),dynamicCommodity.getLimitVal(),dynamicCommodity.getSerLimit(),dynamicCommodity.getSellTime(),dynamicCommodity.getGoodsString(),dynamicCommodity.getPriceTypeString(),dynamicCommodity.getPriceValString(),dynamicCommodity.getDes(),dynamicCommodity.getAddedTime(),dynamicCommodity.getShelfTime(),dynamicCommodity.getStatus(),dynamicCommodity.getCreateDate(),dynamicCommodity.getModifiedDate());
			return i > 0 ? dynamicCommodity : null;
		} catch (Exception e) {
			log.error(e);
			return null;
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public DynamicCommodity insert(DynamicCommodity dynamicCommodity,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insert(dynamicCommodity,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(dynamicCommoditys,conn);
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn){
		return insertBatch(dynamicCommoditys,conn,TABLE_NAME);
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(dynamicCommoditys,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(dynamicCommoditys,conn,tableName);
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int columnSize = 21;
			int size = dynamicCommoditys.size();
			Object[][] params = new Object[size][columnSize];
			for (int i = 0; i < size; i++) {
				params[i][0] =dynamicCommoditys.get(i).getId();
				params[i][1] =dynamicCommoditys.get(i).getName();
				params[i][2] =dynamicCommoditys.get(i).getStoreId();
				params[i][3] =dynamicCommoditys.get(i).getGridString();
				params[i][4] =dynamicCommoditys.get(i).getTagIcon();
				params[i][5] =dynamicCommoditys.get(i).getOpenContType();
				params[i][6] =dynamicCommoditys.get(i).getOpenContVal();
				params[i][7] =dynamicCommoditys.get(i).getWeight();
				params[i][8] =dynamicCommoditys.get(i).getLimitType();
				params[i][9] =dynamicCommoditys.get(i).getLimitVal();
				params[i][10] =dynamicCommoditys.get(i).getSerLimit();
				params[i][11] =dynamicCommoditys.get(i).getSellTime();
				params[i][12] =dynamicCommoditys.get(i).getGoodsString();
				params[i][13] =dynamicCommoditys.get(i).getPriceTypeString();
				params[i][14] =dynamicCommoditys.get(i).getPriceValString();
				params[i][15] =dynamicCommoditys.get(i).getDes();
				params[i][16] =dynamicCommoditys.get(i).getAddedTime();
				params[i][17] =dynamicCommoditys.get(i).getShelfTime();
				params[i][18] =dynamicCommoditys.get(i).getStatus();
				params[i][19] =dynamicCommoditys.get(i).getCreateDate();
				params[i][20] =dynamicCommoditys.get(i).getModifiedDate();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] insertBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(dynamicCommoditys,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(dynamicCommodity,conn);
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity,Connection conn){
		return update(dynamicCommodity,conn,TABLE_NAME);
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return update(dynamicCommodity,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(dynamicCommodity,conn,tableName);
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity,Connection conn,String tableName){
		List<DynamicCommodity> dynamicCommoditys = new ArrayList<DynamicCommodity>();
		dynamicCommoditys.add(dynamicCommodity);
		updateBatch(dynamicCommoditys,conn,tableName);
		return dynamicCommodity;
	}
	
	public DynamicCommodity update(DynamicCommodity dynamicCommodity,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return update(dynamicCommodity,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(dynamicCommoditys,conn);
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn){
		return updateBatch(dynamicCommoditys,conn,TABLE_NAME);
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(dynamicCommoditys,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(dynamicCommoditys,conn,tableName);
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "UPDATE " +tableName+ " SET id = ?,name = ?,storeId = ?,grid = ?,tagIcon = ?,openContType = ?,openContVal = ?,weight = ?,limitType = ?,limitVal = ?,serLimit = ?,sellTime = ?,goods = ?,priceType = ?,priceVal = ?,des = ?,addedTime = ?,shelfTime = ?,status = ?,create_date = ?,modified_date = ? WHERE id = ?";
		try {
			int columnSize = 21;
			int size = dynamicCommoditys.size();
			Object[][] params = new Object[size][columnSize + 1];
			for (int i = 0; i < size; i++) {
				params[i][0] =dynamicCommoditys.get(i).getId();
				params[i][1] =dynamicCommoditys.get(i).getName();
				params[i][2] =dynamicCommoditys.get(i).getStoreId();
				params[i][3] =dynamicCommoditys.get(i).getGridString();
				params[i][4] =dynamicCommoditys.get(i).getTagIcon();
				params[i][5] =dynamicCommoditys.get(i).getOpenContType();
				params[i][6] =dynamicCommoditys.get(i).getOpenContVal();
				params[i][7] =dynamicCommoditys.get(i).getWeight();
				params[i][8] =dynamicCommoditys.get(i).getLimitType();
				params[i][9] =dynamicCommoditys.get(i).getLimitVal();
				params[i][10] =dynamicCommoditys.get(i).getSerLimit();
				params[i][11] =dynamicCommoditys.get(i).getSellTime();
				params[i][12] =dynamicCommoditys.get(i).getGoodsString();
				params[i][13] =dynamicCommoditys.get(i).getPriceTypeString();
				params[i][14] =dynamicCommoditys.get(i).getPriceValString();
				params[i][15] =dynamicCommoditys.get(i).getDes();
				params[i][16] =dynamicCommoditys.get(i).getAddedTime();
				params[i][17] =dynamicCommoditys.get(i).getShelfTime();
				params[i][18] =dynamicCommoditys.get(i).getStatus();
				params[i][19] =dynamicCommoditys.get(i).getCreateDate();
				params[i][20] =dynamicCommoditys.get(i).getModifiedDate();
				params[i][columnSize] =dynamicCommoditys.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] updateBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(dynamicCommoditys,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(dynamicCommodity,conn);
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity,Connection conn){
		return delete(dynamicCommodity,conn,TABLE_NAME);
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return delete(dynamicCommodity,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(dynamicCommodity,conn,tableName);
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int i = run.update(conn,sql, dynamicCommodity.getId());
			return i > 0 ? true : false;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean delete(DynamicCommodity dynamicCommodity,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return delete(dynamicCommodity,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(dynamicCommoditys,conn);
	}
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn){
		return deleteBatch(dynamicCommoditys,conn,TABLE_NAME);
	}
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(dynamicCommoditys,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(dynamicCommoditys,conn,tableName);
	}
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int size = dynamicCommoditys.size();
			Object[][] params = new Object[size][1];
			for (int i = 0; i < size; i++) {
				params[i][0] = dynamicCommoditys.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean deleteBatch(List<DynamicCommodity> dynamicCommoditys,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(dynamicCommoditys,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}

	/**
	 * 根据( id ) 查询
	 */
	public DynamicCommodity getById(int id){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn);
	}
	
	public DynamicCommodity getById(int id,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn,tableName);
	}
	public List<DynamicCommodity> getIn(Set<Integer> ids){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn);
	}
	
	public List<DynamicCommodity> getIn(Set<Integer> ids,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn,tableName);
	}
	
	//Connection
	/**
	 * 根据( id ) 查询
	 */
	public DynamicCommodity getById(int id,Connection conn){
		return getById(id,conn,TABLE_NAME);
	}
	
	public DynamicCommodity getById(int id,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date FROM " + tableName + " WHERE " + "id = ? ORDER BY id ASC LIMIT 1";
		DynamicCommodity dynamicCommodity = null; 
		try {
			dynamicCommodity = run.query(conn,sql, new DynamicCommodityHandler(), id);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return dynamicCommodity;
	}
	public List<DynamicCommodity> getIn(Set<Integer> ids,Connection conn){
		return getIn(ids,conn,TABLE_NAME);
	}
	
	public List<DynamicCommodity> getIn(Set<Integer> ids,Connection conn,String tableName){
		List<DynamicCommodity> dynamicCommoditys = Lists.newArrayList();
		if(ids.isEmpty()) return dynamicCommoditys;
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date FROM " + tableName + " WHERE " + "id in (%s) ORDER BY id ASC";
		sql = String.format(sql, Joiner.on(",").join(ids));
		try {
			dynamicCommoditys = run.query(conn,sql, new DynamicCommodityListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return dynamicCommoditys;
	}
	
	//DataSource
	/**
	 * 根据( id ) 查询
	 */
	public DynamicCommodity getById(int id,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public DynamicCommodity getById(int id,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	public List<DynamicCommodity> getIn(Set<Integer> ids,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<DynamicCommodity> getIn(Set<Integer> ids,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	
	public List<DynamicCommodity> getAll(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn);
	}
	
	public List<DynamicCommodity> getAll(Connection conn){
		return getAll(conn,TABLE_NAME);
	}
	
	public List<DynamicCommodity> getAll(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<DynamicCommodity> getAll(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn,tableName);
	}
	
	public List<DynamicCommodity> getAll(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date FROM " + tableName + " ORDER BY id ASC";
		List<DynamicCommodity> dynamicCommoditys = Lists.newArrayList();
		try {
			dynamicCommoditys = run.query(conn, sql, new DynamicCommodityListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return dynamicCommoditys;
	}
	
	public List<DynamicCommodity> getAll(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public List<DynamicCommodity> getAllPage(int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,page,pageSize);
	}
	
	public List<DynamicCommodity> getAllPage(Connection conn,int page,int pageSize){
		return getAllPage(conn,TABLE_NAME,page,pageSize);
	}
	
	public List<DynamicCommodity> getAllPage(DataSource ds,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<DynamicCommodity> getAllPage(String tableName,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,tableName,page,pageSize);
	}
	
	public List<DynamicCommodity> getAllPage(Connection conn,String tableName,int page,int pageSize){
		QueryRunner run = new QueryRunner();
		page = ((page-1) * pageSize);
		String sql = "SELECT id,name,storeId,grid,tagIcon,openContType,openContVal,weight,limitType,limitVal,serLimit,sellTime,goods,priceType,priceVal,des,addedTime,shelfTime,status,create_date,modified_date FROM " + tableName + " ORDER BY id ASC LIMIT " + page + " , " +pageSize;
		List<DynamicCommodity> dynamicCommoditys = Lists.newArrayList();
		try {
			dynamicCommoditys = run.query(conn, sql, new DynamicCommodityListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return dynamicCommoditys;
	}
	
	public List<DynamicCommodity> getAllPage(DataSource ds,String tableName,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,tableName,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean truncate(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn);
	}
	
	public boolean truncate(Connection conn){
		return truncate(conn,TABLE_NAME);
	}
	
	public boolean truncate(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean truncate(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn,tableName);
	}
	
	public boolean truncate(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "TRUNCATE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean truncate(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	// 执行自定义查询sql
	public List<Map<String,Object>> executeQuerySql(String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String sql){
		return executeQuerySql(conn,TABLE_NAME,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String sql){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,sql);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Map<String,Object>> executeQuerySql(String tableName,String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,tableName);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String tableName,String sql){
		QueryRunner run = new QueryRunner();
		ToolError.isAndTrue(ArtifactErrorCode.SQL_PERMISSIONS_ERROR, !StrUtil.startWithIgnoreCase(sql, "SELECT"));
		List<Map<String,Object>> list = Lists.newArrayList();
		try {
			list = run.query(conn,sql, new MapListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return list;
	}
	/**
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	*/
	
	//
	
	//
	
	//Drop Table
	public boolean drop(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn);
	}
	
	public boolean drop(Connection conn){
		return drop(conn,TABLE_NAME);
	}
	
	public boolean drop(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return drop(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean drop(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn,tableName);
	}
	
	public boolean drop(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DROP TABLE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean drop(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return drop(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	//create
	public boolean createTable(CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,type);
	}
	
	public boolean createTable(Connection conn,CreateTableEnum type){
		return createTable(conn,TABLE_NAME,type);
	}
	
	public boolean createTable(DataSource ds,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean createTable(String tableName,CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,tableName,type);
	}
	
	public boolean createTable(Connection conn,String tableName,CreateTableEnum type){
		QueryRunner run = new QueryRunner();
		SK_Plus plus = SK_Plus.b("CREATE TABLE IF NOT EXISTS `", tableName,"` (");
		plus.a("  `id` INT(11) NOT NULL  COMMENT '',");	
		plus.a("  `name` VARCHAR(45)   COMMENT 'remarks=商品名称',");	
		plus.a("  `storeId` INT(11)   COMMENT 'remarks=所属商店',");	
		plus.a("  `grid` VARCHAR(45)   COMMENT 'remarks=格子编号',");	
		plus.a("  `tagIcon` VARCHAR(45)   COMMENT 'remarks=标签',");	
		plus.a("  `openContType` INT(11)   COMMENT 'remarks=开启条件',");	
		plus.a("  `openContVal` INT(11)   COMMENT 'remarks=开启值',");	
		plus.a("  `weight` INT(11)   COMMENT 'remarks=权重(随机商店生效)',");	
		plus.a("  `limitType` INT(11)   COMMENT 'remarks=限购',");	
		plus.a("  `limitVal` INT(11)   COMMENT 'remarks=限购值',");	
		plus.a("  `serLimit` INT(11)   COMMENT 'remarks=全服限购额外限制个人购买的数量',");	
		plus.a("  `sellTime` VARCHAR(45)   COMMENT 'remarks=出售时间',");	
		plus.a("  `goods` VARCHAR(45)   COMMENT 'remarks=道具',");	
		plus.a("  `priceType` VARCHAR(45)   COMMENT 'remarks=价格类型',");	
		plus.a("  `priceVal` VARCHAR(45)   COMMENT 'remarks=价格数量',");	
		plus.a("  `des` VARCHAR(100)   COMMENT 'remarks=描述',");	
		plus.a("  `addedTime` DATETIME   COMMENT 'remarks=上架时间',");
		plus.a("  `shelfTime` DATETIME   COMMENT 'remarks=下架时间',");
		plus.a("  `status` INT(11)   COMMENT 'remarks=状态',");	
		plus.a("  `create_date` DATETIME   COMMENT '',");
		plus.a("  `modified_date` DATETIME   COMMENT '',");
		plus.a("  PRIMARY KEY (`id`),");
		if (CreateTableEnum.LOGIC.equals(type) || CreateTableEnum.DESIGN.equals(type)) {
			
		}
		if (CreateTableEnum.DESIGN.equals(type)) {
		}
		String sql = plus.e();
		sql = StrUtil.subPre(sql, sql.lastIndexOf(StrUtil.C_COMMA));
		sql+=") ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='remarks=动态商品';";
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean createTable(DataSource ds,String tableName,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,tableName,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getColumnsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"id\",\"NULLABLE\":0,\"REMARKS\":\"\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":1,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"name\",\"NULLABLE\":1,\"REMARKS\":\"remarks=商品名称\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":2,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"storeId\",\"NULLABLE\":1,\"REMARKS\":\"remarks=所属商店\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":3,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"grid\",\"NULLABLE\":1,\"REMARKS\":\"remarks=格子编号\ntype=int[]\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":4,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"tagIcon\",\"NULLABLE\":1,\"REMARKS\":\"remarks=标签\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":5,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"openContType\",\"NULLABLE\":1,\"REMARKS\":\"remarks=开启条件\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":6,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"openContVal\",\"NULLABLE\":1,\"REMARKS\":\"remarks=开启值\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":7,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"weight\",\"NULLABLE\":1,\"REMARKS\":\"remarks=权重(随机商店生效)\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":8,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"limitType\",\"NULLABLE\":1,\"REMARKS\":\"remarks=限购\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":9,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"limitVal\",\"NULLABLE\":1,\"REMARKS\":\"remarks=限购值\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":10,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"serLimit\",\"NULLABLE\":1,\"REMARKS\":\"remarks=全服限购额外限制个人购买的数量\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":11,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"sellTime\",\"NULLABLE\":1,\"REMARKS\":\"remarks=出售时间\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":12,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"goods\",\"NULLABLE\":1,\"REMARKS\":\"remarks=道具\ntype=Map\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":13,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"priceType\",\"NULLABLE\":1,\"REMARKS\":\"remarks=价格类型\ntype=int[]\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":14,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"priceVal\",\"NULLABLE\":1,\"REMARKS\":\"remarks=价格数量\ntype=int[]\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":135,\"ORDINAL_POSITION\":15,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":45}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"des\",\"NULLABLE\":1,\"REMARKS\":\"remarks=描述\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":300,\"ORDINAL_POSITION\":16,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":12,\"TYPE_NAME\":\"VARCHAR\",\"COLUMN_SIZE\":100}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"addedTime\",\"NULLABLE\":1,\"REMARKS\":\"remarks=上架时间\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":17,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"shelfTime\",\"NULLABLE\":1,\"REMARKS\":\"remarks=下架时间\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":18,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"status\",\"NULLABLE\":1,\"REMARKS\":\"remarks=状态\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":19,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"create_date\",\"NULLABLE\":1,\"REMARKS\":\"\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":20,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"SCOPE_TABLE\":null,\"TABLE_CAT\":\"dal_social_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"dynamic_commodity\",\"COLUMN_DEF\":null,\"SCOPE_CATALOG\":null,\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"modified_date\",\"NULLABLE\":1,\"REMARKS\":\"\",\"DECIMAL_DIGITS\":null,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":null,\"ORDINAL_POSITION\":21,\"SCOPE_SCHEMA\":null,\"SOURCE_DATA_TYPE\":null,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getIndexsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_social_design\",\"PAGES\":null,\"TABLE_NAME\":\"dynamic_commodity\",\"TABLE_SCHEM\":null,\"COLUMN_NAME\":\"id\",\"INDEX_NAME\":\"PRIMARY\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_social_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"FILTER_CONDITION\":null,\"TYPE\":3}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
//自定义内容起始位置
class DynamicCommodityHandler implements ResultSetHandler<DynamicCommodity>{
	@Override
	public DynamicCommodity handle(ResultSet rs) throws SQLException {
		return rs.next() ? DynamicCommodity.builder().createForResultSet(rs).syncIndexValues() : null ;
	}
}

class DynamicCommodityListHandler extends AbstractListHandler<DynamicCommodity>{
	@Override
	protected DynamicCommodity handleRow(ResultSet rs) throws SQLException {
		return DynamicCommodity.builder().createForResultSet(rs).syncIndexValues();
	}
}

//自定义内容结束位置
}

